Bdms 227 jab updates to pass tests#255
Closed
jacob-a-brown wants to merge 230 commits into
Closed
Conversation
A polymorphic Notes table was needed to store all unstructured notes. This commit creates the necessary polymorphic Notes table. Its purpose is to store all unstructured notes, categorized by a note_type. It should be used when a record might need more than one note, when the notes need to be categorized, or when you need the ability to search across all notes in the system. This is different from a dedicated notes field on a specific table, which should be used to store a single, intrinsic attribute of the record itself.
This commit introduces a new category, `notable_type`, to the `lexicon.json` file. This category will serve as the central, authoritative source for the controlled vocabulary used in the polymorphic `noteable_type` columns
Removed the TODO comments about updating the lexicon file with 'notable_type' category and values. They have been added.
Added NotesMixin to db/base.py that provides polymorphic note capabilities to any model that inherits from it. The mixin offers: - A polymorphic one-to-many relationship to the Notes table using the notable_id/notable_type pattern - Efficient loading with selectin strategy to prevent N+1 query issues - A convenient add_note() factory method for creating new notes with proper polymorphic associations - Clean separation between read (relationship) and write (method) operations This mixin enables consistent note-taking across multiple entity types while maintaining type safety and relationship integrity.
Added the NotesMixin to both Location and Thing models to enable polymorphic note capabilities. This allows: - Associating multiple categorized notes with locations and things - Consistent note handling across entity types - Type-safe access to notes through relationship loading - Efficient loading of notes with selectin strategy The NotesMixin provides both the notes relationship and add_note() method for these models, enabling a clean API for both reading and creating notes.
…ation models - Created new Pydantic schema for the Notes model - Added polymorphic relationship `notes: List[NoteResponse] = []` to Thing and Location schemas for flexible data modeling.
- Resolved SQLAlchemy inspection error caused by circular import between Notes and Thing/Location models - Updated relationship definitions in notes.py to use string-based SQL expressions instead of direct class references - Maintained TYPE_CHECKING imports for proper type hinting while avoiding runtime circular dependencies
- Fixed the NotesMixin.add_note method by replacing the undefined pk_value reference with self.id - This resolves the "Unresolved reference 'pk_value'" error in base.py - Ensures proper note creation through the convenient factory method - Complements previous circular import fixes in the polymorphic relationship structure The change maintains the intended functionality of creating notes associated with model instances while fixing a reference error that was preventing proper execution.
The lexicon incorrectly categorized a type of note as `noteable_type`. It has been corrected to `note_type` This resolves the error where tests for the location model were unable to locate the proper "note_type".
- Comment out string-type notes fields from CreateLocation and UpdateLocation schemas
- Ensure LocationResponse consistently uses notes as List[NoteResponse]
- Fix validation error where API was receiving string notes but expecting list type
- Complete transition to polymorphic notes relationship for location entities
- Update test data to create proper Note objects instead of using string values
This resolves the ResponseValidationError where the API expected notes to be a list
but received a string value ('these are some test notes').
…t from erase_and_rebuild_db
BDMS 221: well core information
# Conflicts: # transfers/well_transfer.py
Contributor
Author
|
the comparison to bdms 227 is broken and outdated. i'm going to close this and open a new one and that will hopefully fix this bug |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements model/schema updates to pass all well additional information tests except for the aquifer/geology tests. Those will get implemented after the models have been finalized.
@chasetmartin:
the response should include the source of the completion informationseems to apply to the completion date of the well, is that correct?the response should include the source of the construction informationseems to apply to the construction method of the well, is that correct?